<template>
  <div>
    <el-card>
      <div slot="header">
        <el-row :gutter="24">
          <el-col :span="12">
            <strong>实验评价与建议</strong>
          </el-col>
          <!-- <el-col :span="12" class="frx">
            <el-button type="primary" @click="showRate = true">评分</el-button>
          </el-col> -->
        </el-row>
        <el-row :gutter="24" class="flex_item" style="margin-top:20px">
          <strong class="ml_2">综合评分</strong><span class="mx_2" style="color:#f7ba2a">{{aveRate}}</span> <el-rate v-model="aveRate" disabled></el-rate>
        </el-row>
      </div>
      <el-row>
        <el-table :data="source">
          <el-table-column label="姓名" prop="username"></el-table-column>
          <el-table-column label="学校/单位" prop="school"></el-table-column>
          <el-table-column label="实验评价与建议" prop="suggest"></el-table-column>
          <el-table-column label="创建时间">
            <template slot-scope="scope">{{$parseDate(scope.row.createTime)}}</template>
          </el-table-column>
          <el-table-column label="评级">
            <template slot-scope="scope">
              <el-rate v-model="scope.row.star" disabled></el-rate>
            </template>
          </el-table-column>
        </el-table>
      </el-row>
      <el-row>
        <el-pagination
          :page-size="size"
          :current-page.sync="page"
          :total="total"
          @current-change="loadSource()"
        ></el-pagination>
      </el-row>
    </el-card>
    <RateCommentDialog :visible.sync="showRate"></RateCommentDialog>
  </div>
</template>
<script>
import RateCommentDialog from "../../../components/dialog/RateCommentDialog.vue";
import Aapi from "../../../api/Advice.js";
export default {
  data() {
    return {
      showRate: false,
      showDelete:false,
      page: 1,
      size: 15,
      total: 1,
      aveRate: 4.3,
      deleteId:null,
      source: [
        {
          id: 3,
          username: "王五",
          school: "浙师大",
          suggest: "听不懂，差评",
          star: 2,
          createTime: 1565752396000,
          updateTime: 1565752396000
        }
      ]
    };
  },
  components: {
    RateCommentDialog,
  },
  methods: {
    loadSource() {
      this.axios
        .get(Aapi.findAll, {
          params: { pageSize: this.size, pageNum: this.page }
        })
        .then(res => {
          if (res.data.status === 0) {
            this.source = res.data.data.list;
            this.total = res.data.data.total;
          }
        });
    },
    loadAveRate(){
      this.axios.get(Aapi.countMark).then(res=>{
        if(res.data.status===0){
          this.aveRate = res.data.data;
        }
      })
    },
    openDelete(id){
        this.deleteId = id;
        this.showDelete = true;
    },
  },
  mounted() {
    this.loadSource();
    this.loadAveRate();
  }
};
</script>
<style>
</style>